package com.compunit.composite.core.interfaces;

import java.io.IOException;
import java.net.URL;

/**
 * <code>ILauncher</code> defines the interface of the
 * utility runtime unit that is responsible for launching
 * and shutting down a component.
 *
 * @author Yi Wang (Neakor)
 * @version Creation date: 11-13-2009 18:53 EST
 * @version Modified date: 12-05-2009 15:59 EST
 */
public interface ILauncher {
	
	/**
	 * Launch the component with given name with its
	 * cx and class files located in the directory
	 * specified by the given string.
	 * @param directory The <code>URL</code> path
	 * to the directory that contains the component
	 * cx and class files.
	 * @param name The <code>String</code> component
	 * name, which is the same as the cx and class
	 * file names without the extensions.
	 * @param cache <code>true</code> if all data
	 * should be cached at construction time.
	 * @throws IOException If file handling failed.
	 * @throws ClassNotFoundException If the information
	 * cached in the cx importer does not match the data
	 * in the jar file.
	 * @throws InstantiationException If component cannot
	 * be instantiated.
	 * @throws IllegalAccessException If component class
	 * object cannot be accessed correctly.
	 */
	public void launch(final URL directory, final String name, final boolean cache) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException;

	/**
	 * Launch the component with given name with its
	 * cx and class files located in the directory
	 * specified by the given string.
	 * @param directory The <code>URL</code> path
	 * to the directory that contains the component
	 * cx and class files.
	 * @param name The <code>String</code> component
	 * name, which is the same as the cx and class
	 * file names without the extensions.
	 * @param cache <code>true</code> if all data
	 * should be cached at construction time.
	 * @param configfile The <code>URL</code> links
	 * to the configuration file.
	 * @throws IOException If file handling failed.
	 * @throws ClassNotFoundException If the information
	 * cached in the cx importer does not match the data
	 * in the jar file.
	 * @throws InstantiationException If component cannot
	 * be instantiated.
	 * @throws IllegalAccessException If component class
	 * object cannot be accessed correctly.
	 */
	public void launch(final URL directory, final String name, final boolean cache, final URL configfile) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException;
	
	/**
	 * Shutdown the launched component.
	 * @throws Exception If shutting down failed.
	 */
	public void shutdown() throws Exception;
}
